<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>导航条页面</title>
	<link rel="stylesheet" type="text/css" href="app_static/css/nav.css">
</head>
<body>
	<div class="con">
		<div class="header">
			<h1 class="title center">电影票查询</h1>
			<div class="login"></div>
			<div class="nav">
				<ul class="clear center" >
					<li>电影票编号</li>
					<li>电影名称</li>
					<li>座位</li>
					<li>上映时间</li>
				</ul>
			</div>
		</div>
		<div class="bodyer center" id="navbody">
		</div>
		<div class="footer">
			
		</div>
		<div class="tips" id="tips">
			<a href="javascript:buyTicket();">立即抢购</a>
		</div>
		<div class="tips_win">
			<P id="msgs">正在为你抢购...</P>
			<input type="button" value="确定" id="btn_cln" onclick="javascript:flush();">
		</div>
	</div>
	<script type="text/javascript" src="app_static/js/jquery-1.12.2.min.js"></script>
	<script type="text/javascript" src="app_static/js/tips.js"></script>
	<script>
		$(function(){
			var url = "<%=request.getContextPath()%>" + "/showTicket.htm";
			$.ajax({
				url : url,
				dataType : 'json',
				//data : {} ,
				success : function(obj){
		 			var errorCode = obj.errorCode;
					if(errorCode=='0'){
						var tickets = JSON.parse(obj.data);
						var navbody = document.getElementById("navbody");
						for(var i in tickets){
							var ticket = tickets[i] ;
							var col = document.createElement("ul");
							col.setAttribute("class","clear");
							var row = document.createElement("li");
							row.innerHTML = ""+ticket.num+"";
							col.appendChild(row);
							row = document.createElement("li");
							var filmName = "";
							if(ticket.filmID==1){
								filmName = "长城";
							}
							row.innerHTML = filmName;
							col.appendChild(row);
							var line = ticket.line;
							var rows = ticket.row;
							var seat = line+"行"+rows+"排";
							row = document.createElement("li");
							row.innerHTML = seat;
							col.appendChild(row);
							row = document.createElement("li");
							row.innerHTML = ""+ticket.time+"";
							col.appendChild(row);
							navbody.appendChild(col);
						}
					}
				}
			});
		})
		
		function buyTicket(){
			var url = "<%=request.getContextPath()%>" + "/getTicket.htm";
			$.ajax({
				url : url,
				dataType : 'json' ,
				//data : {} ,
				success : function(obj){
					var errorMessage = obj.errorMessage;
					$("#msgs").html(errorMessage);
				}
			});
		}
		
		function flush(){
			location.reload();
		}
	</script>
</body>
</html>